var Text_ajax = function(){
    $.ajax({
        type: "GET",//通常会用到两种：GET,POST。默认是: GET
        url: "../package.json",//发送请求的地址
        dataType: "html",//预期服务器发挥的数据类型。
        beforeSend: beforeSend,//发送请求
        success: callback,//请求成功
        error: error,//请求出错、
        complete: complete//请求完成
    });
    function error(XMLHttpRequest, textStatus, errThrown){
        //通常情况下textStatus和errorThrown只有其中一个有值
        $("#showResult").append("<div>请求出错啦！</div>");
    }
    function complete(XMLHttpRequest, textStatus){
        $("#showResult").append("<div>请求完成</div>");
    }
    function beforeSend(XMLHttpRequest){
        $("#showResult").append("<div>发送请求...</div>");
    }
    function callback(msg){
        $("#showResult").append("<div>请求成功，回传数<br>" + msg + "</div>");
    }
}

var EventUtil = {
	trigger: function(element,type,eventName){
		if(element[type]){
			element[type]();
		}else{
			var e = document.createEvent(eventName);
			e.initEvent(type,true,true);
			element.dispatchEvent(e);
		}
	},
    addListener: function(element, type, callback) {
        if (element.addEventListener) {
            element.addEventListener(type, callback);
        } else if (element.attachEvent) {
            element.attachEvent("on" + type, callback);
        } else {
            element["on" + type] = callback;
        }
    },
    removeListener: function(element, type, callback) {
        if (element.removeEventListener) {
            element.removeEventListener(type, callback);
        } else if (element.detachEvent) {
            element.detachEvent("on" + type, callback);
        } else {
            element["on" + type] = undefined;
        }
    }
}